import { useSelector } from "react-redux"

import { useDigital, useLocale } from "@/hooks"
import { AppState } from "@/stores"
import { handleTotalNumber } from "@/utils/util"

export interface RootObject {
	dataType: string
	creditQuota: number
	newCreditQuota: number
	withdrawAmount: number
	depositAmount: number
	loanAmount: number
	newLoanAmount: number
	shouldRepaymentAmount: number
	shouldPaymentAmount: number
	newEffectiveNum: number
	activeNum: number
	validBetAmount: number
	netAmount: number
	memberRebateAmount: number
	proxyRebateAmount: number
	platformIncomeAmount: number
	totalRepayQuota: number
	newRepayQuota: number
	payType: "payOut" | "payIn"
}

const dataDailyReportColumns = () => {
	const { renderFormat: _renderFormat, renderColor: _renderColor } = useDigital()
	const { newFormat } = useLocale()
	const { currency } = useSelector((state: AppState) => state.config)
	const renderColor = (v: number) => _renderColor(v / 10000)
	const renderFormat = (v: number) => handleTotalNumber(currency.symbol, "10k", v)

	const dataDailyReport_dataType = {
		title: "report.dataType",
		width: 80,
		render: (v: string) => {
			switch (v) {
				case "1":
					return newFormat("report.dataType1")
				case "2":
					return newFormat("report.dataType2")
				case "3":
					return newFormat("report.dataType3")
				default:
					return "-"
			}
		}
	}
	const dataDailyReport_creditQuota = {
		title: "report.creditQuota",
		width: 200,
		render: renderFormat
	}
	const dataDailyReport_newCreditQuota = {
		title: "report.newCreditQuota",
		width: 200,
		render: renderFormat
	}
	const dataDailyReport_withdrawAmount = {
		title: "report.withdrawAmount",
		width: 200
	}
	const dataDailyReport_depositAmount = {
		title: "report.depositAmount",
		width: 200
	}
	const dataDailyReport_loanAmount = {
		title: "report.loanAmount",
		width: 200,
		render: renderFormat
	}
	const dataDailyReport_newLoanAmount = {
		title: "report.newLoanAmount",
		width: 200,
		render: renderFormat
	}
	const dataDailyReport_shouldRepaymentAmount = {
		title: "report.shouldRepaymentAmount",
		width: 200,
		render: renderFormat
	}
	const dataDailyReport_shouldPaymentAmount = {
		title: "report.shouldPaymentAmount",
		width: 200,
		render: renderFormat
	}
	const dataDailyReport_newEffectiveNum = {
		title: "report.newEffectiveNum",
		width: 200,
		render: renderFormat
	}
	const dataDailyReport_activeNum = {
		title: "report.activeNum",
		width: 200,
		render: renderFormat
	}
	const dataDailyReport_validBetAmount = {
		title: "report.validBetAmount",
		width: 200
	}
	const dataDailyReport_netAmount = {
		title: "report.netAmount",
		width: 200,
		render: renderColor
	}
	const dataDailyReport_memberRebateAmount = {
		title: "report.memberRebateAmount",
		width: 200,
		render: renderFormat
	}
	const dataDailyReport_proxyRebateAmount = {
		title: "report.proxyRebateAmount",
		width: 200,
		render: renderFormat
	}
	const dataDailyReport_platformIncomeAmount = {
		title: "report.platformIncomeAmount",
		width: 200,
		render: renderColor
	}
	const dataDailyReport_totalRepayQuota = {
		title: "report.totalRepayQuota",
		width: 200,
		render: renderFormat
	}
	const dataDailyReport_newRepayQuota = {
		title: "report.newRepayQuota",
		width: 200,
		render: renderFormat
	}

	const dataDailyReport_channelName = {
		title: "report.channelName",
		width: 120
	}
	const dataDailyReport_placedOrders = {
		title: "report.placedOrders",
		width: 120
	}
	const dataDailyReport_totalOrders = {
		title: "report.totalOrders",
		width: 120
	}
	const dataDailyReport_successfulOrders = {
		title: "report.successfulOrders",
		width: 120
	}
	const dataDailyReport_successfulRate = {
		title: "report.successfulRate",
		width: 120
	}
	const dataDailyReport_amount = {
		title: "report.amount",
		width: 200,
		render: renderColor
	}

	return {
		dataDailyReport_dataType,
		dataDailyReport_creditQuota,
		dataDailyReport_newCreditQuota,
		dataDailyReport_withdrawAmount,
		dataDailyReport_depositAmount,
		dataDailyReport_loanAmount,
		dataDailyReport_newLoanAmount,
		dataDailyReport_shouldRepaymentAmount,
		dataDailyReport_shouldPaymentAmount,
		dataDailyReport_newEffectiveNum,
		dataDailyReport_activeNum,
		dataDailyReport_validBetAmount,
		dataDailyReport_netAmount,
		dataDailyReport_memberRebateAmount,
		dataDailyReport_proxyRebateAmount,
		dataDailyReport_platformIncomeAmount,
		dataDailyReport_totalRepayQuota,
		dataDailyReport_newRepayQuota,
		dataDailyReport_channelName,
		dataDailyReport_placedOrders,
		dataDailyReport_totalOrders,
		dataDailyReport_successfulOrders,
		dataDailyReport_successfulRate,
		dataDailyReport_amount
	}
}

export default dataDailyReportColumns
